#!/bin/bash

cat >$HOME/.fetchmailrc <<EOF
poll imap.exmail.qq.com protocol imap:
username "your email username" password "your email password" 

folder '&UXZO1mWHTvZZOQ-/pms'
ssl
keep
mda "/usr/bin/procmail -m $HOME/.procmailrc"
EOF

cat >$HOME/.procmailrc <<EOF
MAILDIR=\$HOME/Mail
LOGFILE=\$HOME/.procmail.log
DEFAULT=\$MAILDIR/pms/

SHELL=/bin/bash
export LANG=en_US
DATE=\`date +%b\`
:0
*^Date.*\$DATE
| xargs rm
EOF

echo "修改./fetchmail 文件属性为600"
chmod 600 ~/.fetchmailrc

go build -o main main.go 

sudo apt update
sudo apt install -y fetchmail procmail 
echo "done"
echo "NOTE  !!!!!!! NOTE"
echo "请修改配置文件:~/.fetchmailrc ~/.procmailrc"
echo "请修改配置文件:~/.fetchmailrc中的folder,username,password"
echo "请查看并修改run.sh中的MAILPATH"
